package com.qf.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created with IntelliJ IDEA. User: Administrator Date: 2021/11/16 0016 Time: 16:58 Description: No
 * Description
 */
@Configuration
public class RebbitMqConfig {

  @Bean(name = "emailQueue")
  public Queue emailQueue() {

    return new Queue("qfshop-email-queue");
  }

  @Bean(name = "SmsQueue")
  public Queue SmsQueue() {

    return new Queue("qfshop-sms-queue");
  }

  @Bean(name = "infomationTopicExchange")
public TopicExchange infomationTopicExchange(){
      return new TopicExchange("qfshop-information-topic");
  }

  @Bean
public Binding bindSmsToQueue(@Qualifier("SmsQueue")Queue queue,@Qualifier("infomationTopicExchange")TopicExchange topicExchange){
      return BindingBuilder.bind(queue).to(topicExchange).with("#.sms");
  }

@Bean
public Binding bindEmailToQueue(@Qualifier("emailQueue")Queue queue,@Qualifier("infomationTopicExchange")TopicExchange topicExchange){
    return BindingBuilder.bind(queue).to(topicExchange).with("email.#");
}
}
